package com.presentacion.houseon;

import com.control.houseon.ControlHouseON;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

public class LoginActivity extends Activity implements OnClickListener {

	Button btnC;
	TextView txtuser, txtpass;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		//requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.activity_login);
		//getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_barra_titulo);
		
		btnC=(Button)findViewById(R.id.btnConectar);
		btnC.setOnClickListener(this);
		
		
		txtuser=(TextView)findViewById(R.id.txtUsuario);
		txtpass=(TextView)findViewById(R.id.txtPassword);
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.login, menu);
		return true;
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v==btnC){
			
			String us= txtuser.getText().toString();
			String ps= txtpass.getText().toString();
			
			int id =ControlHouseON.getInstancia().login(us,ps);
			if(id>0){
			Intent i= new Intent(LoginActivity.this, ListaCasaActivity .class);
			startActivity(i);
			//i.putExtra("idCasa", id);
			}
		}
		
	}

}
